//
//  ViewController.m
//  Test_Thresh
//
//  Created by 王子曦 on 2025/5/14.
//

#import "ViewController.h"
#import <thresh/Thresh.h>
#import "ThreshSupport/ThreshConfig.h"
#import "ThreshSupport/Loader.h"
#import "ThreshSupport/NativeBridge.h"
#import "ThreshSupport/InfoCollector.h"

@interface ViewController ()
@property (nonatomic, strong) ThreshConfig *config;
@property (nonatomic, strong) ThreshViewController *threshViewController; // 添加强引用
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.config = [ThreshConfig new];
    
    // 创建一个按钮来打开Thresh页面
    UIButton *openThreshButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [openThreshButton setTitle:@"打开Thresh页面" forState:UIControlStateNormal];
    openThreshButton.frame = CGRectMake(100, 200, 200, 50);
    [openThreshButton addTarget:self action:@selector(openThreshPage) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:openThreshButton];
}

// 打开Thresh页面的方法
- (void)openThreshPage {
    // 创建并展示Thresh页面
    self.threshViewController = [[ThreshViewController alloc] initWithConfig:self.config];
    
    // 检查是否有导航控制器
    if (self.navigationController) {
        [self.navigationController pushViewController:self.threshViewController animated:YES];
    } else {
        // 如果没有导航控制器，则以模态方式呈现
        [self presentViewController:self.threshViewController animated:YES completion:nil];
    }
}


@end